Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@feathersjs/commons
Advanced tools
@feathersjs/commons is a utility library for the Feathers framework, providing a set of common utilities and helper functions that can be used across different parts of a Feathers application. These utilities help with various tasks such as object manipulation, promise handling, and other common programming patterns.
Object manipulation
The @feathersjs/commons package provides utilities for object manipulation, such as picking specific properties from an object.
const { _ } = require('@feathersjs/commons');
const obj = { a: 1, b: 2, c: 3 };
const picked = _.pick(obj, 'a', 'c');
console.log(picked); // { a: 1, c: 3 }
Promise handling
The package includes utilities for handling promises, such as converting callback-based functions to promise-based ones using `promisify`.
const { promisify } = require('@feathersjs/commons');
const callbackFunction = (data, callback) => {
setTimeout(() => callback(null, data), 1000);
};
const promiseFunction = promisify(callbackFunction);
promiseFunction('Hello, world!').then(result => console.log(result)); // 'Hello, world!'
Deep object merging
The package provides utilities for deep merging of objects, which is useful for combining configuration objects or state.
const { merge } = require('@feathersjs/commons');
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { b: { d: 3 }, e: 4 };
const merged = merge({}, obj1, obj2);
console.log(merged); // { a: 1, b: { c: 2, d: 3 }, e: 4 }
Lodash is a popular utility library that provides a wide range of functions for common programming tasks, including object manipulation, array operations, and more. It is more comprehensive and widely used compared to @feathersjs/commons.
Bluebird is a fully-featured promise library that provides powerful extensions to the native JavaScript promises. It offers more advanced promise handling capabilities compared to the promise utilities in @feathersjs/commons.
Deepmerge is a library specifically designed for deep merging of JavaScript objects. It is more focused and specialized for this task compared to the general utilities provided by @feathersjs/commons.
Shared Feathers utility functions
npm install @feathersjs/commons --save
Refer to the Feathers API for more details.
Copyright (c) 2024 Feathers contributors
Licensed under the MIT license.
FAQs
Shared Feathers utility functions
We found that @feathersjs/commons demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.